#ifndef YEP_UI_CHECK_BUTTON_HPP
#define YEP_UI_CHECK_BUTTON_HPP

#include "ButtonBase.hpp"
namespace yep
{
    /**
     * @brief A simple checkbuttom
     **/
    class CheckButton:public ButtonBase
    {
    public:
        /**
         * @brief Draws
         **/
        void onDraw( SDL_Surface* screen )
        {
            style->drawCheckButton( screen, status(), text(), isFocused(), _checked, getAbsolutePosition(), getAbsoluteArea(),
                                    getTextColor(), getBackgroundColor() );
        }

        /**
         * @brief Just do the checking thing
         **/
        void onAction()
        {
            _checked = !_checked;
            ButtonBase::onAction();
        }

        /**
         * @brief Constructor
         **/
        CheckButton()
        {
            _checked = false;
        }

        /**
         * @brief Returns whether it is checked
         **/
        bool checked() const
        {
            return _checked;
        }

        /**
         * @brief Checks or unchecks
         **/
        void checked( bool value )
        {
            _checked = value;
        }

        virtual void autoResize()
        {
            Uint16 w, h;
            style->checkButtonArea( text(), w, h );
            Rect newArea( getRect() );
            if( newArea.w() < w )
                newArea.setW( w );
            if( newArea.h() < h )
                newArea.setH( h );
            setRect( newArea );
        }

    private:
        bool _checked;
    };

}

#endif // YEP_UI_CHECK_BUTTON_HPP

